package com.gl.saasservice.sys.utils;

import com.gl.saasservice.sys.vo.AppUserVO;
import com.gl.saasservice.sys.vo.DepartmentVO;
import com.gl.saasservice.sys.vo.PermissionVO;
import com.gl.saasservice.sys.vo.RoleVO;
import org.apache.commons.lang3.StringUtils;

public class CheckUtil {

    private boolean flag = false;
    private String message = "";

    public Boolean isNull(){
        return flag;
    }
    public String getMessage(){
        return message;
    }

    public void checkValues(DepartmentVO departmentVO){
        if (StringUtils.isBlank(departmentVO.getName())) {
            flag = true;
            this.message = "部门名称不能为空!";
        }
    /*    if (StringUtils.isBlank(departmentVO.getCode())) {
            flag = true;
            this.message = "部门编码不能为空!";
        }*/
    /*    if (departmentVO.getCode().length() !=3) {
            flag = true;
            this.message = "部门编码长度必须为3位!";
        }*/
        if (departmentVO.getSortby() == null) {
            flag = true;
            this.message = "排序编号不能为空!";
        }
    }

/*    public void checkValues(ParamVO paramVO){
        if (StringUtils.isBlank(paramVO.getName())){
            flag = true;
            this.message = "参数名称不能为空";
        }
        if (StringUtils.isBlank(paramVO.getParamValue())){
            flag = true;
            this.message = "参数值不能为空";
        }
    }*/

    public void checkValues(PermissionVO permissionVO){
        if (permissionVO.getParentId() == null) {
            flag = true;
            this.message = "权限父ID不能为空!";
        }
        if (StringUtils.isBlank(permissionVO.getName())) {
            flag = true;
            this.message = "权限名称不能为空！";
        }
        if (permissionVO.getType() == null) {
            flag = true;
            this.message = "权限类型不能为空！";
        }
        if (StringUtils.isBlank(permissionVO.getCode())) {
            flag = true;
            this.message = "权限编码不能为空！";
        }
//        if (StringUtils.isBlank(permissionVO.getUrl())) {
//            flag = true;
//            this.message = "权限路径不能为空！";
//        }
//        if (StringUtils.isBlank(permissionVO.getMethod())) {
//            flag = true;
//            this.message = "权限方法不能为空！";
//        }
        if (permissionVO.getSortby() == null) {
            flag = true;
            this.message = "排序编号不能为空！";
        }
    }

    public void  checkValues(RoleVO roleVO){
        if (StringUtils.isBlank(roleVO.getCode())){
            flag = true;
            this.message = "角色编码不能为空!";
        }
        if (StringUtils.isBlank(roleVO.getDescription())){
            flag = true;
            this.message = "角色描述不能为空!";
        }
        if (StringUtils.isBlank(roleVO.getName())){
            flag = true;
            this.message = "角色名称不能为空!";
        }
    }

    public void checkValues(AppUserVO userVO){
        if (StringUtils.isBlank(userVO.getName())){
            flag = true;
            this.message = "用户姓名不能为空！";
        }
        if (userVO.getStatus() == null){
            flag = true;
            this.message = "用户状态不能为空！";
        }
        if (StringUtils.isBlank(userVO.getPhone())){
            flag = true;
            this.message = "用户联系方式不能为空！";
        }

    }
}
